
export const getImage = (str: string) => {
  if (str?.startsWith('http')) {
    return str
  } 
  if (str?.startsWith('data:image')) {
    return str
  }
  return str ? `data:image/png;base64,${str}` : ''
}

// 日期转换大写
export const dateToChinese = (date: any) => {
  if (date) {
    const dateStr = date?.split(' ')[0]
    let chinese = ['〇', '一', '二', '三', '四', '五', '六', '七', '八', '九', '十']
    let numStr = dateStr.replace(/[^0-9]+/g, '')
    let year = chinese[numStr[0]] + chinese[numStr[1]] + chinese[numStr[2]] + chinese[numStr[3]]
    let month = numStr[4] === '0' ? chinese[numStr[5]] : (chinese[10] + (numStr[5] > 0 ? chinese[numStr[5]] :''))
    let day = ''
    if (numStr[6] === '0') {
      day = chinese[numStr[7]]
    } else if (numStr[6] === '1') {
      if (numStr[7] === '0') {
        day = chinese[10]
      } else {
        day = chinese[10] + chinese[numStr[7]]
      }
    } else if (numStr[6] === '2' || numStr[6] === '3') {
      if (numStr[7] === '0') {
        day = chinese[numStr[6]] + chinese[10]
      } else {
        day = chinese[numStr[6]] + chinese[10] + chinese[numStr[7]]
      }
    }
    return year + ' 年 ' + month + ' 月 ' + day + ' 日 '
  }
}